#include "common_data.h"

void flight_task_init(flight_task_t* ptr){
  ptr->hight = 0;
  ptr->start_time = 0;
  ptr->hang_time = 0;
}

void fc_tlm_init(fc_tlm_t* ptr){
  ptr->flight_mode = Unknown;
  ptr->gps_fix = NoGps;
  ptr->actuators_count = 0;
  ptr->hight = 0.0;
  ptr->speed = 0.0;
  fail_init(&ptr->fail);
}

void ftc_tlm_init(ftc_tlm_t* ptr){
  ptr->state_flg = STATE_INIT;
  ptr->timer_1 = 0;
  ptr->timer_2 = 0;
  ptr->event = EVENT_UNKNOWN;
}

void bc_tlm_init(bc_tlm_t* ptr){
  ptr->temperature = 0.0;
}

void fail_init(fail_t* ptr){
  ptr->type = FAIL_UNDEFINED;
  ptr->time = 0;
}

void gcs_tlm_print(const gcs_tlm_t tlm){
  printf("Telemetry:\n");

  printf("\tFTC:\n");
  printf("\t\tState:\t%d\n", (int)tlm.ftc_tlm.state_flg);
  printf("\t\tTimer1:\t%d\n", (int)tlm.ftc_tlm.timer_1);
  printf("\t\tTimer2:\t%d\n", (int)tlm.ftc_tlm.timer_2);

  printf("\tFC:\n");
  printf("\t\tFlight mode:\t%d\n", (int)tlm.fc_tlm.flight_mode);
  printf("\t\tGps fix:\t%d\n", (int)tlm.fc_tlm.gps_fix);
  printf("\t\tActs count:\t%d\n", (int)tlm.fc_tlm.actuators_count);
  for(int i = 0; i < 6; ++i)
    printf("\t\t\tmotor %d:\t%d\n", i, (int)tlm.fc_tlm.actuators[i]);
  printf("\t\tHight:\t%f\n", tlm.fc_tlm.hight);
  printf("\t\tVelocity:\t%f\n", tlm.fc_tlm.speed);

  printf("\tBC:\n");
  printf("\t\tTemperature:\t%f\n", tlm.bc_tlm.temperature);
}
